#ifndef __WEBPAGE_H__
#define __WEBPAGE_H__
#define LOGGER_LEVEL LL_WARN 

#include "SplitTool.h"
#include "Configuration.h"

#include <string.h>

#include <vector>
#include <map>
#include <set>
#include <string>

#include "../simhash/Simhasher.hpp"
using namespace simhash;

using std::string;
using std::vector;
using std::map;
using std::set;

class Configuration;
class SplitTool;

static Simhasher simhasher("../simhash/dict/jieba.dict.utf8", "../simhash/dict/hmm_model.utf8", "../simhash/dict/idf.utf8", "../simhash/dict/stop_words.utf8");

class WebPage
{
public:
    WebPage(string &doc, Configuration *pconf);
    ~WebPage();

    WebPage(const WebPage &rhs)
    : _doc(rhs._doc)
    , _docContent(rhs._docContent)
    , _docTitle(rhs._docTitle)
    , _docId(rhs._docId)
    , _topWords(rhs._topWords)
    , _wordsMap(rhs._wordsMap)    
    {
    }

    int getDocId();
    string getDoc();
    map<string, int> &getWordsMap();
    // uint64_t getSimhash();

    friend bool operator==(const WebPage &lhs, const WebPage &rhs);
    friend bool operator<(const WebPage &lhs, const WebPage &rhs);

    static bool Compare(const WebPage &lhs, const WebPage &rhs) {
        return lhs < rhs;
    }
private:
    void processDoc(const string &doc, Configuration &conf, SplitTool &splittool);
    void calcTopK(vector<string> &wordsVec, int k, set<string> &stopWordList);

private:
    string _doc;
    int _docId;
    string _docTitle;
    string _docContent;
    vector<string> _topWords;
    map<string, int> _wordsMap;
};

static SplitTool spl;
static SplitTool *_staticsplitTool = &spl;
static Configuration con("../conf/myconf.conf");
static Configuration *_pconf = &con;
#endif
